<#if ft??>
    <div>
        <span style="width: 100%;align-content: center">
            <span style="font-size: 20px;color: #d58512">去程机票信息</span><br>
            <span style="font-size: 11px;color: blue">
                航空公司 : ${ft.airlineName} | 航班号 : ${ft.flightNum} | 机型 : ${ft.planeType}<br>
                出发城市 : ${ft.fromCityName} | 到达城市 : ${ft.toCityName} | 价格 : ${ft.basePrice}<br>
                起飞时间 : ${ft.takeoffTime?string("HH:mm")} | 降落时间 : ${ft.landingTime?string("HH:mm")} | 时间差 : ${ft.timeDifference}<br>
            </span>
        </span>
    </div>
</#if>
<div class="f-sortbar" style="display: block;">
    <div class="navbar-sub clearfix">
        <input type="hidden" name="fromCityCodeby" id="fromCityCodeby" value="${qo.fromCityCode}">
        <input type="hidden" name="toCityCodeby" id="toCityCodeby" value="${qo.toCityCode}">
        <input type="hidden" name="takeoffTimeby" id="takeoffTimeby" value="${(qo.takeoffTime!'')?string('yyyy-MM-dd')}">
        <#if qo.returnTime??>
        <input type="hidden" name="returnTimeby" id="returnTimeby" value="${(qo.returnTime!'')?string('yyyy-MM-dd')}">
        </#if>
        起飞机场：
        <select class="com-opt" id="takeoffPortName" name="takeoffPortName">
            <option value="">不限</option>
            <#list takeoffPortNames as t >
                <option value="${t}">${t}</option>
            </#list>
        </select>
        <script>
            $("#takeoffPortName").val('${qo.takeoffPortName !''}')
        </script>

        到达机场：
        <select class="com-opt" id="landingPortName" name="landingPortName">
            <option value="">不限</option>
            <#list landingPortNames as t >
                <option value="${t}">${t}</option>
            </#list>
        </select>
        <script>
            $("#landingPortName").val('${qo.landingPortName !''}')
        </script>

        航空公司：
        <select class="com-opt" id="airlineName" name="airlineName">
            <option value="">不限</option>
            <#list airlineNames as t >
                <option value="${t}">${t}</option>
            </#list>
        </select>
        <script>
            $("#airlineName").val('${qo.airlineName !''}')
        </script>

        机型：
        <select class="com-opt" id="planeType" name="planeType">
            <option value="">不限</option>
            <#list planeTypes as t >
                <option value="${t}">${t}</option>
            </#list>
        </select>
        <script>
            $("#planeType").val('${qo.planeType !''}')
        </script>

    </div>
</div>
    <div class="f-sortbar">
        <div class="loading-bar"><span id="progress_bar" style="width: 100%; display: none;"></span></div>
        <ul class="clearfix">
            <li class="item1">航空信息</li>
            <li class="item3" ng-click="sortByTakeoffTime()"><span class="f-sort" id="sort_dep_time">起飞时间<i
                    class="up"></i><i class="down"></i></span></li>
            <li class="item3" ng-click="sortByArrTime()"><span class="f-sort" id="sort_arr_time">到达时间<i
                    class="up"></i><i class="down"></i></span></li>
            <li class="item4" ng-click="sortByPrice()"><span class="f-sort" id="sort_price">价格<i
                    class="up"></i><i class="down"></i></span></li>
        </ul>
    </div>
<#list list as f>
    <div id="airinfo">
        <div id="flight_list">
            <div class="f-list ng-scope">
                <div class="f-item">
                    <div class="f-item-info" style="position: relative">
                        <div class="f-line">
                            <span class="airline-logo"><i class="airline-logo-9C"></i></span>
                            <p><span class="f-name ng-binding">${f.airlineName}</span> <span
                                    class="ng-binding">${f.flightNum}</span></p>
                            <p><span class="sub ng-binding">${f.planeTypeDesc}</span> <span
                                    class="ng-binding">${f.planeType}</span></p>
                        </div>
                        <div class="f-time">
                            <div class="time ng-binding">${f.takeoffTime?string("HH:mm")}</div>
                            <p class="sub ng-binding">${f.takeoffPortName}</p>
                        </div>
                        <div class="through">
                            <div class="line-wrapper">
                                <div class="line-time">${f.timeDifference}</div>
                                <div class="line"></div><!----></div>
                        </div>
                        <div class="f-time">
                            <div class="time ng-binding">${f.landingTime?string("HH:mm")}</div>
                            <p class="sub ng-binding">${f.landingPortName}</p>
                        </div>

                        <div class="f-time">
                            ￥ <span style="font-size: 26px;color:#F00">${f.basePrice}</span> 起
                        </div>

                        <#if qo.returnTime??>
                            <div onclick="kickback(${f.id})">选择去程</div>
                        <#else>
                           <div onclick="dianji(${f.id})">选座</div>
                        </#if>

                    </div>
                </div>
            </div>

            <div class="" style="position: relative;display: none" name="${f.id}">
                <#list f.cabinInfos as c>
                    <p>舱位 : ${c.cabinGrade} | 价格 : ${c.nitTicketPrice} | 剩余数量 : ${c.cabin}
                        <#if ft??>
                            <button type="button" onclick="dinggou(${f.id},${c.id},${ft.id})">订购</button>
                        <#else>
                            <button type="button" onclick="dinggou(${f.id},${c.id})">订购</button>
                        </#if>
                    </p>
                </#list>
            </div>
        </div>
    </div>
</#list>


<script>

    function dianji(fid) {

        console.log(fid);
        if ($('div [name=' + fid + ']').css('display') == 'block') {

            $('div [name=' + fid + ']').css('display', 'none');

        } else {

            $('div [name=' + fid + ']').css('display', 'block');

        }
    }


    $(".com-opt").change(function () {

        $("#searchForm").ajaxForm(function (data) {
            $("#travelPage").html(data);
        });

        $("#searchForm").submit();
    });

    function kickback(fid) {
        var fromCityCode = $('#fromCityCode').val();
        var toCityCode = $('#toCityCode').val();
        var takeoffTime = $('#takeoffTime').val();
        var returnTime = $('#returnTime').val();
        $.get('/flight/searchKickback', {
            'fromCityCode': fromCityCode,
            'toCityCode': toCityCode,
            'takeoffTime': takeoffTime,
            'returnTime': returnTime, 'fid': fid
        }, function (data) {
            $("#travelPage").html(data);

            var fromCityCodeby = $('#fromCityCodeby').val();
            var toCityCodeby = $('#toCityCodeby').val();
            var takeoffTimeby = $('#takeoffTimeby').val();
            var returnTimeby = $('#returnTimeby').val();

            $('#fromCityCode').val(fromCityCodeby);
            $('#toCityCode').val(toCityCodeby);
            $('#takeoffTime').val(takeoffTimeby);
            $('#returnTime').val(returnTimeby);
        });


    }

    function dinggou(fid, cid, ftid) {

        if(!ftid){
            ftid = '';
        };

        window.location.href = '/flight/indent?fid='+fid+'&cid='+cid+'&ftid='+ftid

    }
</script>